﻿using System;
using System.Collections.Generic;
using Urbania.GUI.Elements;
using Microsoft.Xna.Framework;
using Urbania.World;
using Urbania.Tiles;

namespace Urbania.GUI
{
    public class StatsBox : PopUp
    {

        public bool isDone = false;

        public StatsBox(int i, Tile t, Vector2 position) : base()
        {
            this.Background = Color.Blue;
            this.Bounds = new Rectangle((int)position.X, (int)position.Y, 300, 200);
            this.Title = "Tile Stats Box";
            this.lua = Program.lua;

            #region switch
            Tile newTile = null;
            switch ((TileType)i)
            {
                case TileType.Road:
                    newTile = new Road(t);
                    break;
                case TileType.Buil_Factory:
                    newTile = new Factory(t);
                    break;
                case TileType.Buil_PowerPlant:
                    newTile = new PowerPlant(t);
                    break;
                case TileType.Buil_CityHall:
                    newTile = new CityHall(t);
                    break;
                case TileType.Buil_Farm:
                    newTile = new Farm(t);
                    break;
                case TileType.Buil_FireStation:
                    newTile = new FireStation(t);
                    break;
                case TileType.Buil_Harbor:
                    newTile = new Harbor(t);
                    break;
                case TileType.Buil_HomelessShelter:
                    newTile = new HomelessShelter(t);
                    break;
                case TileType.Buil_Hospital:
                    newTile = new Hospital(t);
                    break;
                case TileType.Buil_House:
                    newTile = new House(t);
                    break;
                case TileType.Buil_LargeStore:
                    newTile = new LargeStore(t);
                    break;
                case TileType.Buil_Police:
                    newTile = new Police(t);
                    break;
                case TileType.Buil_School:
                    newTile = new School(t);
                    break;
                case TileType.Buil_SmallStore:
                    newTile = new SmallStore(t);
                    break;
                case TileType.Env_Beach:
                    newTile = new Beach(t);
                    break;
                case TileType.Env_Forest:
                    newTile = new Forest(t);
                    break;
                case TileType.Env_Grass:
                    newTile = new Grass(t);
                    break;
                case TileType.Env_Ice:
                    newTile = new Ice(t);
                    break;
                case TileType.Env_Mountains:
                    newTile = new Mountains(t);
                    break;
                case TileType.Env_Water:
                    newTile = new Water(t);
                    break;
                case TileType.Env_Dirt:
                    newTile = new Dirt(t);
                    break;
                default:
                    newTile = new Dirt(t);
                    break;
            }
            #endregion

            Button ok = new Button("Build", new Vector2((int)position.X + 70, (int)position.Y + 150), "Buy", 1, ref this.lua, "Quit.lua", this);
            ok.UseSpecialUpdate(newTile, ((TileType)i).ToString());
            Button cancel = new Button("Cancel", new Vector2((int)position.X + 140, (int)position.Y + 150), "Cancel", 1, ref this.lua, "Quit.lua", this);

            TextElement title = new TextElement(new Vector2((int)position.X, (int)position.Y+00), "Cost", "Build a " + newTile.Filename + "?", Color.White, this);
            TextElement mcost = new TextElement(new Vector2((int)position.X, (int)position.Y+30), "Cost", "Money Cost: " + newTile.CostMoney, Color.White, this);
            TextElement bcost = new TextElement(new Vector2((int)position.X, (int)position.Y+50), "Cost", "Bureaucracy Cost: " + newTile.CostBureauc, Color.White, this);
            TextElement polcost = new TextElement(new Vector2((int)position.X, (int)position.Y+70), "Cost", "Polution: " + newTile.RatePollution * 12 + " p1m.", Color.White, this);
            TextElement happcost = new TextElement(new Vector2((int)position.X, (int)position.Y+90), "Cost", "Happiness: " + newTile.RateHappiness * 12 + " p1m.", Color.White, this);

            this.AddElement(ok);
            this.AddElement(title);
            this.AddElement(cancel);
            this.AddElement(mcost);
            this.AddElement(bcost);
            this.AddElement(polcost);
            this.AddElement(happcost);
            this.parent = Components.WorldComponent.container.GetBaseFrame();
        }
    }
}
